//
// Created by 74176 on 2022/2/9.
//
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string divide(string str,int x){
    int reminder=0;//余数
    int current;//当前运算位
    for(int i=0;i<str.size();i++){
        current=reminder*10+str[i]-'0';
        str[i]=current/x+'0';
        reminder=current%x;
    }
    int pos=0;
    while(str[pos]=='0') pos++;
    return str.substr(pos);
}
string multiple(string str,int x){//
    int carry=0;
    int current;
    for(int i=str.size()-1;i>=0;i--){
        current=carry+(str[i]-'0')*x;
        str[i]=current%10+'0';
        carry=current/10;
    }
    if(carry!=0)
        str="1"+str;
    return str;
}
string add(string str,int x){
    int carry=x;
    int current;
    for(int i=str.size()-1;i>=0;i--){
        current=carry+(str[i]-'0');
        str[i]=current%10+'0';
        carry=current/10;
    }
    if(carry!=0)
        str="1"+str;
    return str;
}//1 2 3 4
// 4 3 2 1
int main(){
    string str;
    while(cin>>str){
        vector<int> binary;
        while (str.size()!=0){
            int last=str[str.size()-1]-'0';
            binary.push_back(last%2);
            str= divide(str,2);
        }
        string answer="0";
        for(vector<int>::iterator it=binary.begin();it!=binary.end();it++){
            answer= multiple(answer,2);
            answer= add(answer,*it);
        }
        cout<<answer<<endl;
    }
    return 0;
}
